package com.example.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.administrator.sharker_demo.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 作    者 ： 文欢
 * 时    间 ： 2017/4/14.
 * 描    述 ：
 * 修改时间 ：
 */

public class LoginActivity extends Activity {
    @BindView(R.id.head_topreturn_img)
    ImageView headTopreturnImg;
    @BindView(R.id.head_title_tv)
    TextView headTitleTv;
    @BindView(R.id.alldata_course_tv)
    TextView alldataCourseTv;
    @BindView(R.id.alldata_course_img)
    ImageView alldataCourseImg;
    @BindView(R.id.zc_text_login)
    TextView zcTextLogin;
    @BindView(R.id.dl_text_login)
    TextView dlTextLogin;
    @BindView(R.id.et_number_login)
    EditText etNumberLogin;
    @BindView(R.id.et_password_login)
    EditText etPasswordLogin;
    @BindView(R.id.nopassword_text_login)
    TextView nopasswordTextLogin;
    @BindView(R.id.btn_login)
    Button btnLogin;
    @BindView(R.id.img_weixin_login)
    ImageView imgWeixinLogin;
    @BindView(R.id.img_sina_login)
    ImageView imgSinaLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.zc_text_login, R.id.dl_text_login, R.id.nopassword_text_login, R.id.btn_login, R.id.img_weixin_login, R.id.img_sina_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.zc_text_login:
                break;
            case R.id.dl_text_login:
                break;
            case R.id.nopassword_text_login:
                Intent intent = new Intent(com.example.ui.activity.LoginActivity.this,NoPasswordActivity.class);
                startActivity(intent);
                break;
            case R.id.btn_login:
                login();
                break;
            case R.id.img_weixin_login:
                break;
            case R.id.img_sina_login:
                break;
        }
    }
    private void login() {
        String numebr = etNumberLogin.getText().toString().trim();
        String password = etPasswordLogin.getText().toString().trim();
        if (TextUtils.isEmpty(numebr) || TextUtils.isEmpty(password)) {
            Toast.makeText(com.example.ui.activity.LoginActivity.this, "账号或者密码为空", Toast.LENGTH_SHORT).show();
        } else {
            //登录
            login(numebr);
        }
    }
    private void login(String numebr) {
        Intent intent = new Intent(com.example.ui.activity.LoginActivity.this,MainActivity.class);
        startActivity(intent);
    }
}
